<?php
require("./include/fpdf/fpdf.php");
include "_fpdf_mc_table.php";

//Instanciation of inherited class
$pdf=new PDF();
$pdf->AliasNbPages();
//$pdf->AddPage('L');
$pdf->SetFont('Times','',9);
$pdf->SetWidths($w);

$data = array();
$fields = $header;
// fetch all data into array ...
$c = 1;
foreach($cawangan_arr as $cawangan):
	$fill = true;
	
	$SQL = sprintf($sql, " WHERE kh.cawangan='".$cawangan."' ORDER BY no_ahli");
	//$SQL = sprintf($sql, " WHERE kh.cawangan='".$cawangan."' ORDER BY nama_ahli");
	$res = $DB->Execute($SQL);
	$cawangan = ($cawangan == '' || empty($cawangan)) ? '--Tiada Maklumat--' : $cawangan;
	$title = 'Senarai Ahli Insuran : Cawangan '. $cawangan;
	$pdf->AddPage('L');
	while($d = $res->FetchNextObject()){
	$i++;
		$x = 0;
		$data = array();
		$data[] = $c;
		for($z=1; $z<count($fields); $z++){
			$data[] = $d->$fields[$z];
		}
		$pdf->row($data, $fill);
		$fill=!$fill;
		$c++;
	}
	$c=1;
endforeach;	

$pdf->Output();
?>